//我的结构赋值
{
    let {0:a,1:b,2:c=3}=[1,2];
    console.log(a,b,c);
}

{
    let a,b,rest;
    [a,b]=[1,2];

    console.log(a,b);
}

{
    let a,b,rest;
    [a,b,...rest]=[1,2,3,4,5,6];

    console.log(a,b,rest);
}

{
   let a,b;
    //这里用括号包起来就是为了,防止兼容性问题.
    //有些浏览器会把它看成一个块级作用域.
    //但是其实是一个结构赋值.
    //在babel当中也会出错.
    ({a,b}={a:1,b:2});
    console.log(a,b)
}

{
    //关于默认值
    let a,b,c;
    [a,b,c=3]=[1,2];
    console.log(a,b,c);
}

{
    //关于值的交换
    let a=1,
        b=2;
    [a,b]=[b,a];
    console.log(a,b);
}


{
    let {p:a,q:b}={p:42,q:true};
    console.log(a,b);
}




